<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>color6</title>
  <script src="./color6.js"></script>
</head>
<body>
  
  <input id="input" />
  <color-6 id="color6"></color-6>
  <script>

    //注册color6组件
    window.customElements.define("color-6",Color6);

    //触发事件的控件
    let input = document.querySelector("#input");

    //输入框聚焦时打开颜色控件
    input.onfocus=function(){
      let color6 = document.querySelector("#color6");
      color6.open({
        sender:this,      //触发的控件
        value:this.value, //初始的颜色
        format:"hex",     //输出格式:hsl,rgb,hex
        onchose:(color)=>{
          this.value=color;
        }
      });
    }
    
  </script>
</body>
</html>